package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EstimatedEventMapper;
import com.ruoyi.system.domain.EstimatedEvent;
import com.ruoyi.system.service.IEstimatedEventService;
import com.ruoyi.common.core.text.Convert;

/**
 * 指标事件Service业务层处理
 *
 * @author ruoyi
 * @date 2021-10-29
 */
@Service
public class EstimatedEventServiceImpl implements IEstimatedEventService {
    @Autowired
    private EstimatedEventMapper estimatedEventMapper;

    /**
     * 查询指标事件
     *
     * @param id 指标事件主键
     * @return 指标事件
     */
    @Override
    public EstimatedEvent selectEstimatedEventById(Long id) {
        return estimatedEventMapper.selectEstimatedEventById(id);
    }

    /**
     * 查询指标事件列表
     *
     * @param estimatedEvent 指标事件
     * @return 指标事件
     */
    @Override
    public List<EstimatedEvent> selectEstimatedEventList(EstimatedEvent estimatedEvent) {
        return estimatedEventMapper.selectEstimatedEventList(estimatedEvent);
    }

    /**
     * 新增指标事件
     *
     * @param estimatedEvent 指标事件
     * @return 结果
     */
    @Override
    public int insertEstimatedEvent(EstimatedEvent estimatedEvent) {
        return estimatedEventMapper.insertEstimatedEvent(estimatedEvent);
    }

    /**
     * 修改指标事件
     *
     * @param estimatedEvent 指标事件
     * @return 结果
     */
    @Override
    public int updateEstimatedEvent(EstimatedEvent estimatedEvent) {
        return estimatedEventMapper.updateEstimatedEvent(estimatedEvent);
    }

    /**
     * 批量删除指标事件
     *
     * @param ids 需要删除的指标事件主键
     * @return 结果
     */
    @Override
    public int deleteEstimatedEventByIds(String ids) {
        return estimatedEventMapper.deleteEstimatedEventByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除指标事件信息
     *
     * @param id 指标事件主键
     * @return 结果
     */
    @Override
    public int deleteEstimatedEventById(Long id) {
        return estimatedEventMapper.deleteEstimatedEventById(id);
    }

    @Override
    public void getMyEstimated(Integer pageNumber, Integer lines, String enteredBy, HashMap<String, Object> hs) {
        pageNumber = null == pageNumber ? 0 : pageNumber;
        lines = null == lines ? 0 : lines;
        if (null == enteredBy || "".equals(enteredBy.trim())) {
            hs.put("DBList", null);
            hs.put("DBAccount", 0);
            return;
        }
        List<EstimatedEvent> userList = estimatedEventMapper.getByUserList(pageNumber, lines, enteredBy);
        Long count = estimatedEventMapper.getCountForUser(enteredBy);
        hs.put("DBList", userList);
        hs.put("DBAccount", count);
    }

    @Override
    public List<EstimatedEvent> getByEventTime(String eventTime) {
        return estimatedEventMapper.getByEventTime(eventTime);
    }


    @Override
    public int getAllImportCount(String theme) {
        return estimatedEventMapper.getAllImportCount(theme);
    }

    @Override
    public int getAllImportCount2(String theme) {
        return estimatedEventMapper.getAllImportCount2(theme);
    }

    @Override
    public List<EstimatedEvent> getAllImport(Integer pageNumber, Integer lines, String theme) {
        pageNumber = null == pageNumber ? 0 : pageNumber;
        lines = null == lines ? 0 : lines;
        return estimatedEventMapper.getAllImport(pageNumber,lines,theme);
    }

    @Override
    public List<EstimatedEvent> getAllImport2(Integer pageNumber, Integer lines,String theme) {
        pageNumber = null == pageNumber ? 0 : pageNumber;
        lines = null == lines ? 0 : lines;
        return estimatedEventMapper.getAllImport2(pageNumber,lines,theme);
    }

}
